package Pantallas;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.container.AbsoluteFieldManager;
import net.rim.device.api.ui.container.GridFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;
import GUI.BitmapButtonField;
import GUI.ShortcutHandler;
import Main.MyApp;
/**
 * A class extending the MainScreen class, which provides default standard
 * behavior for BlackBerry GUI applications.
 */
public final class PantallaInicio extends Pantalla
{	
	private int width;
	private int height;
	private static VentanaInicioSesion ventIS;
	private static VentanaRegistrarTelf ventRT;
	//private static Usuario user;
    /**
     * Creates a new MyScreen object
     */
    public PantallaInicio(){        
    	super();
    	this.addKeyListener (new ShortcutHandler());
        width  = MyApp.getWidth();
        height = MyApp.getHeight();
    	Bitmap bitmap = Bitmap.getBitmapResource("x.png");
    	
        BitmapButtonField b  = new BitmapButtonField(bitmap, bitmap,0);
       
        EditField b1 = new EditField("Usuario: ",null);
        b1.setMaxSize(10);
        
        // Set up the 
		GridFieldManager gfm1 = new GridFieldManager(1, 2, GridFieldManager.FIXED_SIZE);
		gfm1.setColumnPadding(5);
	
		gfm1.setBorder(BorderFactory.createSimpleBorder( new XYEdges(0, 0, 0, 0),  Border.STYLE_DASHED)); 
		 
		// Size the columns of the GridFieldManager. Make sure to calculate 
		// for the padding applied to the columns. 
		int columnWidth = (width /2) - gfm1.getColumnPadding() + 175;
		
		int rowHeight   = (height /2) - gfm1.getColumnPadding() + 190;
		
		for(int i = 0; i < 1; i++) {
			gfm1.setColumnProperty(i, GridFieldManager.FIXED_SIZE, columnWidth);
			gfm1.setRowProperty(i, GridFieldManager.FIXED_SIZE, rowHeight);
		} 
		
		AbsoluteFieldManager afm = new AbsoluteFieldManager();
		// Populate the columns. 
		afm.add(b,110,80);
		//afm.add(b1,150,100);
		
		gfm1.add(afm);
		gfm1.setBackground(BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("i3.jpg")));
		
		add(gfm1);
    }
    
    /**
     * 
     * 
     */
    public static void iniciarSesion(){
    	//
    	UiApplication.getUiApplication().invokeLater( 
			new Runnable() { 
				public void run() { 
					String[] buttons = { "Aceptar", "Cancelar" };
			    	ventIS = new VentanaInicioSesion(buttons);
			     	ventIS.show();
				} 
			});    	
    }
    
    /**
     * 
     */
    public static void registrarTelf(){
    	//
    	String[] buttons = { "Aceptar", "Cancelar" };
    	ventRT = new VentanaRegistrarTelf(buttons);
     	ventRT.show();
     	
    }
}



	 

		


